package com.collectplus.express.self;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;

import com.collectplus.express.BaseActivity2;
import com.collectplus.express.R;
import com.collectplus.express.tools.SharedPref;
import com.collectplus.express.wxapi.Constants;

import java.util.ArrayList;
import java.util.List;

import droid.frame.view.ViewPagerExt;

/**
 * 三步搞定投递袋
 *
 * @author lidandan<br>
 *         2017-10-31下午6:00:42
 */
public class SelfUserPassportActivity extends BaseActivity2 implements OnClickListener {
    private ViewPagerExt mViewPager;
    private final int PAGE_SIZE = 3;// 示例数量

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        overridePendingTransition(R.anim.in_bottom2top, 0);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void findViewById() {
        setContentView(R.layout.self_user_passport);
        super.findViewById();
        mViewPager = (ViewPagerExt) findViewById(R.id.view_pager);
        findViewById(R.id.close_iv).setOnClickListener(this);
        loadImage();
    }

    private void loadImage() {
        List<View> pager = new ArrayList<View>();
        for (int i = 0; i < PAGE_SIZE; i++) {
            int resId = getResources().getIdentifier("self_first_send_" + (i + 1), "drawable", getPackageName());
            LinearLayout parms = new LinearLayout(getContext());
            parms.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
            parms.setBackgroundResource(resId);
            pager.add(parms);
        }
        mViewPager.setViewItems(pager, false);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.close_iv:
                finish();
                break;
            default:
                break;
        }
    }

    @Override
    public void finish() {
        SharedPref.setFirstOpen(Constants.isShowOrderTip, false);
        super.finish();
        overridePendingTransition(0, R.anim.out_top2bottom);
    }
}
